//
//  OAMainCell.m
//  OA项目
//
//  Created by innofive on 2018/4/13.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAMainCell.h"

@interface OAMainCell ()

@end

@implementation OAMainCell

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *titles =@[@"通知公告",@"审批管理",@"财务报表",@"利润表"];
    NSArray *imageNames =@[@"one2",@"one3",@"one",@"one"];
    NSMutableArray *buttons =[NSMutableArray arrayWithCapacity:titles.count];
    int m = 0;
    for (NSString *title in titles) {
        UIButton *btn = ({
            UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
            [l setNormalTitle:title];
            [l setNormalImage:IMAGE(imageNames[m])];
            [l AddTarget:ViewController Action:@selector(onClickButton:)];
            l.titleLabel.font = kSysFont(kFitW(12));
            [l setNormalTitleColor:[UIColor blackColor]];
            l.tag = m+10;
            [view addV:l];
            l;
        });
        [buttons addObject:btn];
        m++;
    }
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        CGFloat w = size.width/titles.count;
        int h= 0;
        for (UIButton *btn in buttons) {
            btn.frame = CGRectMake(w*h, 0, w, size.height);
            [btn layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleTop) imageTitleSpace:3];
            h++;
        }
    }];
    
}


@end




@interface OAMainCell1 ()

@end

@implementation OAMainCell1

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.imageView.image = IMAGE(@"tongzhi");
    
    self.textLabel.text = @"关于2017年端午节放假安排通知";
    self.textLabel.font = kSysFont(kFitW(12));
    self.detailTextLabel.text = @"2017-05-5";
    self.detailTextLabel.font = kSysFont(kFitW(12));
    
}
-(void)update:(OANoticeListModel *)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.textLabel.text = model.title;
    self.detailTextLabel.text = model.publishTime;
}

@end

@interface OAMainCell2 ()
{
    UILabel *_label1;
}
@end

@implementation OAMainCell2

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.imageView.image = IMAGE(@"tongzhi");
    
    self.textLabel.text = @"关于2017年端午节放假安排通知";
    self.textLabel.font = kSysFont(kFitW(12));
    self.detailTextLabel.text = @"英诺科技有限公司";
    self.detailTextLabel.font = kSysFont(kFitW(12));
    
    UILabel *label1 = ({
        UILabel *l = [UILabel new];
        l.text = @"2017-05-5";
        l.font = kSysFont(kFitW(12));
        [view addV:l];
        l;
    });
    _label1 = label1;
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        
        
        [label1 sizeToFit];
        label1.centerY =weakSelf.textLabel.centerY;
        label1.right = size.width-kFitW(10);
    }];
}
-(void)update:(OANoticeListModel *)model forTableView:(UITableView *)tableView AtIndexPath:(NSIndexPath *)indexPath
{
    self.textLabel.text = model.title;
    self.detailTextLabel.text = model.publishCopr;
    _label1.text =model.publishTime;
}


@end




@interface OAMainHeaderFooterView ()

@end

@implementation OAMainHeaderFooterView
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{

    SDCycleScrollView *crollView = ({
        SDCycleScrollView *l = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:ViewController placeholderImage:nil];
        l.infiniteLoop = YES;
        l.autoScroll = YES;
        l.showPageControl = YES;
        l.localizationImageNamesGroup = @[IMAGE(@"main1"),IMAGE(@"main2")];
        [view addV:l];
        l;
    });
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        crollView.frame= CGRectMake(0, 0, size.width,size.height);
    }];
    
}
@end







@interface OAMainHeaderFooterView1 ()

@end

@implementation OAMainHeaderFooterView1
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(id)dataSource AtSection:(NSInteger)section
{
    
    self.backgroundColor = hexCOLOR(@"FFF9E8");
    
    self.textLabel.text = @"最新公告";
    
    
    UILabel *label = ({
        UILabel *l = [UILabel new];
        l.text = @"NEW";
        l.textColor = hexCOLOR(@"FF8900");
        l.font = kSysFont(kFitW(13));
        l.borderWidth = 1;
        l.borderColor =hexCOLOR(@"FF8900");
        l.textAlignment = NSTextAlignmentCenter;
        l.masksToBounds = YES;
        [view addV:l];
        l;
    });
    
    UILabel *label1 = ({
        UILabel *l = [UILabel new];
        l.text = @"更多";
        l.textColor =[UIColor blackColor];
        [l addTarget:ViewController action:@selector(onClickHeaderView:)];
        l.font = kSysFont(kFitW(13));
        [view addV:l];
        l;
    });
    
    
    UIImageView *imageV = ({
        UIImageView *l = [UIImageView new];
        l.image = IMAGE(@"jiantou");
        [view addV:l];
        l;
    });
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
     
        weakSelf.textLabel.centerY =size.height/2;
        
        label.size = CGSizeMake(kFitW(50), kFitH(25));
        label.centerY =weakSelf.textLabel.centerY;
        label.left = weakSelf.textLabel.right+kFitW(10);
        
        [imageV sizeToFit];
        imageV.right = size.width-kFitW(10);
        imageV.centerY = size.height/2;
        
        [label1 sizeToFit];
        label1.right = imageV.left;
        label1.centerY = size.height/2;
        
    }];
    
}
@end

